﻿@namespace BootstrapBlazor.Components
@typeparam TValue
@inherits SingleUploadBase<TValue>

@if (IsShowLabel)
{
    <BootstrapLabel required="@Required" ShowLabelTooltip="ShowLabelTooltip" Value="@DisplayText" />
}
<div @attributes="@AdditionalAttributes" class="@ClassString" id="@Id">
    <div class="upload-body is-avatar">
        @if (IsUploadButtonAtFirst && CheckCanUpload())
        {
            @RenderAdd
        }
        @foreach (var item in GetUploadFiles())
        {
            <div class="@GetItemClassString(item)" id="@item.ValidateId" style="@PrevStyleString">
                <Avatar Url="@item.PrevUrl" />
                @if (!IsDisabled)
                {
                    <div class="upload-item-actions">
                        <span class="upload-item-delete" @onclick="@(e => OnFileDelete(item))">
                            <i class="@DeleteIcon"></i>
                        </span>
                        @if (GetShowProgress(item))
                        {
                            <span class="upload-item-spin">
                                <i class="@LoadingIcon"></i>
                            </span>
                        }
                    </div>
                }
                @if (!IsCircle)
                {
                    <span class="upload-item-label">
                        <i class="@ValidStatusIconString"></i>
                        <i class="@InvalidStatusIconString"></i>
                    </span>
                }
            </div>
        }
        @if (!IsUploadButtonAtFirst && CheckCanUpload())
        {
            @RenderAdd
        }
    </div>
    <InputFile AdditionalAttributes="@GetUploadAdditionalAttributes()" OnChange="OnFileChange" />
</div>


@code {
    RenderFragment RenderAdd =>
    @<div class="@ItemClassString" style="@PrevStyleString">
        <div class="upload-item-actions btn-browser">
            <span class="upload-item-plus">
                <i class="@AddIcon"></i>
            </span>
        </div>
    </div>;
}
